import 'package:blog/base/get/get_save_state_view.dart';
import 'package:blog/widget/card_widget_item.dart';
import 'package:blog/widget/pull_smart_refresher.dart';
import 'package:blog/widget/recommond_card_item.dart';
import 'package:flutter/material.dart';
import 'package:waterfall_flow/waterfall_flow.dart';
import 'ask_controller.dart';

/// @class : ProjectPage
/// @date : 2021/08/23
/// @name : CTGU_LLZ(404name)
/// @description :项目 View层
class AskPage extends GetSaveView<AskController> {
  const AskPage({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      backgroundColor: Colors.white,
      body: SafeArea(
        top: true,
        child: RefreshWidget<AskController>(
          child: WaterfallFlow.builder(
            //cacheExtent: 0.0,
            padding: EdgeInsets.all(5.0),
            gridDelegate: SliverWaterfallFlowDelegateWithFixedCrossAxisCount(

              crossAxisCount: 2,
              crossAxisSpacing: 5.0,
              mainAxisSpacing: 5.0,
              viewportBuilder: (int firstIndex, int lastIndex) {
                print('viewport : [$firstIndex,$lastIndex]');
                print(controller.projectData.length);
                if (lastIndex >= controller.projectData.length) {
                  //手动刷新
                  print("加载新数据");
                }
              },
              lastChildLayoutTypeBuilder: (index) =>
                  index > controller.projectData.length
                      ? LastChildLayoutType.foot
                      : LastChildLayoutType.none,
            ),
            itemBuilder: (BuildContext context, int index) {
              return CardWidgetItem(
                detail: controller.projectData[index],
              );
            },
            itemCount: controller.projectData.length,
          ),
        ),
      ),
    );
  }
}
